
/*
 *	文字管理器
 *	统一管理点阵、freetype矢量字体等字库
 */
#include <font_manager.h>
#include <string.h>

static pFontOpr g_ptFonts = NULL;	//字库链表，存放底层支持的字库类型的结构体
static pFontOpr g_ptDefaultFontopr = NULL;

void RegisterFont(pFontOpr ptFontOpr)
{
	ptFontOpr->ptNext = g_ptFonts;
	g_ptFonts = ptFontOpr;
}



void FontsSystemRegister(void)
{
	//注册freetype字库结构体,由底层提供
	FreetypeRegister();
}

/*
 *	args: aFontOprname：字库结构体名
 *		  aFontFileName：字体名
 */
int SelectAndInitFont(char *aFontOprname, char *aFontFileName)
{
	pFontOpr ptCur = g_ptFonts;
	while(ptCur != NULL)
	{
		if(strcmp(ptCur->name, aFontOprname) == 0)
		{
			break;
		}
		ptCur = ptCur->ptNext;
	}
	if(ptCur == NULL)
	{
		return -1;
	}
	g_ptDefaultFontopr = ptCur;
	return ptCur->FontInit(aFontFileName);
}

int SetFontSize(int iFontSize)
{
	return g_ptDefaultFontopr->SetFontSize(iFontSize);
}

int GetFontBitMap(unsigned int dwCode, pFontBitMap ptFontBitMap)
{
	return g_ptDefaultFontopr->GetFontBitMap(dwCode, ptFontBitMap);
}

int GetStringRegionCar (char *str, PRegionCartesian ptRegionCar)
{
	return g_ptDefaultFontopr->GetStringRegionCar(str, ptRegionCar);
}


